﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="myphotodetail.aspx.vb" Inherits="WSADProject.myphotodetail" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .auto-style1 {
            width: 157px;
        }
        .auto-style2 {
            width: 539px;
        }
        .auto-style4 {
            width: 539px;
            height: 34px;
        }
        .auto-style6 {
            height: 34px;
            text-align: center;
            width: 109px;
        }
 
  
               


        .Controls {
            text-align: center;
        }
 
  
               


    </style>
   
    <script type="text/javascript" src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyC6v5-2uaq_wusHDktM9ILcqIrlPtnZgEk&sensor=false">
</script>
<script type="text/javascript">
    function initialize() {
        var markers = JSON.parse('<%=ConvertDataTabletoString() %>');
        var mapOptions = {
            center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
            zoom: 12,
            mapTypeId: google.maps.MapTypeId.SATELLITE
            //  marker:true
        };
        var infoWindow = new google.maps.InfoWindow();
        var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
        for (i = 0; i < markers.length; i++) {
            var data = markers[i]
            var myLatlng = new google.maps.LatLng(data.lat, data.lng);
            var marker = new google.maps.Marker({
                position: myLatlng,
                map: map,
                title: data.title
            });
            (function (marker, data) {

                // Attaching a click event to the current marker
                google.maps.event.addListener(marker, "click", function (e) {
                    infoWindow.setContent(data.description);
                    infoWindow.open(map, marker);
                });
            })(marker, data);
        }
      
    }

    function hidemap() {
        document.getElementById('map_canvas').style.display = "none";
    }
    function showmap() {
        initialize();
        document.getElementById('map_canvas').style.display = "block";
    }
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
  
  <div style="text-align:center">
      <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Account/myphotos.aspx">Back to Photos</asp:HyperLink></div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
   
   <div id="ajaxrating">
         
                <asp:Label ID="lbltxt" runat="server"></asp:Label>
               <ajaxToolkit:Rating ID="Rating1" CurrentRating="0" MaxRating="10" 
                    CssClass="ratingStar"
                    StarCssClass="ratingItem"
                    WaitingStarCssClass="Saved"
                    FilledStarCssClass="Filled"
                    EmptyStarCssClass="Empty" AutoPostBack="True"
                    RatingAlign ="Horizontal" RatingDirection="LeftToRightTopToBottom"
            runat="server" HorizontalAlign="Left" Enabled ="false" >  
        </ajaxToolkit:Rating>
       </div>
    <div id ="tagphoto">
        <asp:Button ID="btnShowPopup" runat="server" Text="Add Tag"/>
        <asp:Button ID="Button2" runat="server" Text="Button" style="display:none"/>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="Button2" PopupControlID="pnlpopup"
CancelControlID="btnCancel" BackgroundCssClass="modalBackground">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="pnlpopup" runat="server" BackColor="White" style="display:block">

    <asp:CheckBoxList ID="CheckBoxList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="TagDescription" DataValueField="TagID" RepeatDirection="Horizontal"></asp:CheckBoxList>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:fishconn %>" ProviderName="<%$ ConnectionStrings:fishconn.ProviderName %>" SelectCommand="SELECT [TagID], [TagDescription] FROM [tblTags]"></asp:SqlDataSource>
<br /><asp:Button ID="btnAdd" CommandName="Update" runat="server" Text="Update"/>
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</asp:Panel>
    </div>
    
    <asp:ListView ID="ListView2" runat="server" DataKeyNames="PhotoID" DataSourceID="SqlDataSource3">
        <AlternatingItemTemplate>
           
    <table style="width:100%;">
        <tr>
            <td colspan ="2">
                 
                
                 <asp:Image ID="Profilepic" ImageUrl='<%# String.Format("~/{0}", Eval("Url"))%>' runat="server" />

            </td>
            
        </tr>
         <tr><td colspan ="2">
           <table style="width:100%;">
               <tr><td>Comments</td>
                   <td>Likes</td>
                   <td>Tags</td>
               </tr>
                <tr>
                    <td><asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource5">
                     <ItemTemplate>
                    
                                <asp:Label ID="CommentsLabel" runat="server" Text='<%# Eval("Comments") %>' /> by 
                          
                                <asp:Label ID="UsernameLabel" runat="server" Text='<%# Eval("Username")%>' />
                           on 
                                <asp:Label ID="CommDateLabel" runat="server" Text='<%# Eval("CommDate", "{0:d}")%>' />
                           at
                                <asp:Label ID="CommmTimeLabel" runat="server" Text='<%# Eval("CommmTime", "{0:T}")%>' />
                          
                     </ItemTemplate>                   
                </asp:Repeater>
               
                <asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:fishconn %>" ProviderName="<%$ ConnectionStrings:fishconn.ProviderName %>" SelectCommand="SELECT [Username], [Comments], [CommDate], [CommmTime] FROM [tblPhotoComments] WHERE ([PhotoID] = ?) ORDER BY [CommDate], [CommmTime]">
                    <SelectParameters>
                        <asp:QueryStringParameter Name="PhotoID" QueryStringField="PhotoID" Type="Int32" />
                    </SelectParameters>

                </asp:SqlDataSource></td>
                    <td><asp:Repeater ID="Repeater4" runat="server" DataSourceID="SqlDataSource2">
                     <ItemTemplate>
                      <asp:Label ID="UsernameLabel" runat="server" Text='<%# Eval("Username") %>' />
                        </ItemTemplate>

                </asp:Repeater>
                <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:fishconn %>" ProviderName="<%$ ConnectionStrings:fishconn.ProviderName %>" SelectCommand="SELECT [Username] FROM [tblPhotoLike] WHERE ([PhotoID] = ?) ORDER BY [PhotoLikeID] DESC">
               <SelectParameters>
                   <asp:QueryStringParameter Name="PhotoID" QueryStringField="PhotoID" Type="Int32" />
               </SelectParameters>
           </asp:SqlDataSource>

                    </td>
                    <td> <asp:Repeater ID="Repeater3" runat="server" DataSourceID ="SqlDataSource4">
                         <ItemTemplate>
                   
                           <asp:Label ID="TagDescriptionLabel" runat="server" Text='<%# Eval("TagDescription") %>' />
                  
               </ItemTemplate>

                         </asp:Repeater>

                        <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:fishconn %>" ProviderName="<%$ ConnectionStrings:fishconn.ProviderName %>" SelectCommand="SELECT tblTags.TagDescription FROM (tblPhotoTag INNER JOIN tblTags ON tblPhotoTag.TagID = tblTags.TagID) WHERE (tblPhotoTag.PhotoID = ?)">
               <SelectParameters>
                   <asp:QueryStringParameter Name="?" QueryStringField="PhotoID" />
               </SelectParameters>
           </asp:SqlDataSource>
                    </td>
                </tr>
            </table>
            </td>
        </tr>
      
        <tr>
            <td class="auto-style1">
                <asp:CheckBox ID="chkProfilePict" runat="server" /></td>
            <td class="auto-style2">Set as Profile Picture</td>
            
        </tr>
        <tr>
            <td class="auto-style1">
                Date Uploaded</td>
            <td class="auto-style2">
                <asp:Label ID="lbldateup" runat="server" Text='<%# Eval("Dateupload", "{0:d}")%>'></asp:Label>
            </td>
            
        </tr>
        <tr>
            <td class="auto-style1">
                Time Uploaded</td>
            <td class="auto-style2">
               <asp:Label ID="lbltimeup" runat="server" Text='<%# Eval("TimeUpload", "{0:T}")%>'></asp:Label>
            </td>
            
        </tr>
        <tr>
            <td class="auto-style1">Caption:</td>
            <td class="auto-style2">
                <asp:TextBox ID="txtCaption" runat="server" Text='<%# Bind("Caption")%>' Height="89px" TextMode="MultiLine" Width="238px"></asp:TextBox></td>
            
        </tr>
        <tr>
            <td class="auto-style1">Latitude</td>
            <td class="auto-style2">
                <asp:TextBox ID="TxtLat" runat="server" Text='<%# Eval("LatLoc", "{0:n2}")%>' CausesValidation="True"></asp:TextBox>
                 <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="TxtLat" ValidationExpression="^[-+]?\d*\.?\d*$" ErrorMessage="Enter a valid number" ForeColor="Red"></asp:RegularExpressionValidator>
                 <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TxtLat" ErrorMessage="Latitude is required" ForeColor="Red"></asp:RequiredFieldValidator>
                  <asp:RangeValidator ID="RangeValidator2" runat="server" ErrorMessage="RangeValidator" ControlToValidate="TxtLat" ForeColor="Red" MaximumValue="180" MinimumValue="-180" type="Double">-180 To 180</asp:RangeValidator>
             </td>
    
        </tr>
           <tr>
            <td class="auto-style1">Longitude</td>
            <td class="auto-style2"><asp:TextBox ID="TxtLong" runat="server" Text='<%# Eval("LongLoc", "{0:n2}")%>' CausesValidation="True"></asp:TextBox>
                  <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TxtLong" ValidationExpression="^[-+]?\d*\.?\d*$" ErrorMessage="Enter a valid Number" ForeColor="Red"></asp:RegularExpressionValidator> 
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TxtLong" ErrorMessage="Longitudeis Required" ForeColor="Red"></asp:RequiredFieldValidator>
                  <asp:RangeValidator ID="RangeValidator3" runat="server" ErrorMessage="RangeValidator" ControlToValidate="TxtLong" ForeColor="Red" MaximumValue="180" MinimumValue="-180" type="Double">-180 To 180</asp:RangeValidator>
                 </td>
               
        </tr>
  </table>
     <asp:HiddenField ID="hiddenphotoid" runat="server" Value='<%# Bind("PhotoID")%>' />
             <asp:HiddenField ID="Hiddensmallurl" runat="server" Value='<%# Bind("SmallUrl")%>' />
 

        </AlternatingItemTemplate>
        <EditItemTemplate>
            <span style="">Url:
            <asp:TextBox ID="UrlTextBox" runat="server" Text='<%# Bind("Url") %>' />
            <br />
            Dateupload:
            <asp:TextBox ID="DateuploadTextBox" runat="server" Text='<%# Bind("Dateupload") %>' />
            <br />
            TimeUpload:
            <asp:TextBox ID="TimeUploadTextBox" runat="server" Text='<%# Bind("TimeUpload") %>' />
            <br />
            Caption:
            <asp:TextBox ID="CaptionTextBox" runat="server" Text='<%# Bind("Caption") %>' />
            <br />
            LatLoc:
            <asp:TextBox ID="LatLocTextBox" runat="server" Text='<%# Bind("LatLoc") %>' />
            <br />
            LongLoc:
            <asp:TextBox ID="LongLocTextBox" runat="server" Text='<%# Bind("LongLoc") %>' />
            <br />
            PhotoID:
            <asp:Label ID="PhotoIDLabel1" runat="server" Text='<%# Eval("PhotoID") %>' />
            <br />
            <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
            <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
            <br /><br /></span>
        </EditItemTemplate>
        <EmptyDataTemplate>
            <span>No Picture found.</span>
        </EmptyDataTemplate>
        <InsertItemTemplate>
            <span style="">Url:
            <asp:TextBox ID="UrlTextBox" runat="server" Text='<%# Bind("Url") %>' />
            <br />Dateupload:
            <asp:TextBox ID="DateuploadTextBox" runat="server" Text='<%# Bind("Dateupload") %>' />
            <br />TimeUpload:
            <asp:TextBox ID="TimeUploadTextBox" runat="server" Text='<%# Bind("TimeUpload") %>' />
            <br />Caption:
            <asp:TextBox ID="CaptionTextBox" runat="server" Text='<%# Bind("Caption") %>' />
            <br />LatLoc:
            <asp:TextBox ID="LatLocTextBox" runat="server" Text='<%# Bind("LatLoc") %>' />
            <br />LongLoc:
            <asp:TextBox ID="LongLocTextBox" runat="server" Text='<%# Bind("LongLoc") %>' />
            <br />
            <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
            <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
            <br /><br /></span>
        </InsertItemTemplate>
         <ItemTemplate>
    <table style="width:100%;">
        <tr>
            <td colspan ="2">
                 <asp:Image ID="Profilepic" ImageUrl='<%# String.Format("~/{0}", Eval("Url"))%>' runat="server" />

            </td>
            
        </tr>
             <tr><td colspan ="2">
           <table style="width:100%;">
               <tr><td>Comments</td>
                   <td>Likes</td>
                   <td>Tags</td>
               </tr>
                <tr>
                    <td>
                        
                        <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource5">
                        
                     <ItemTemplate>
                    
                                <%# Eval("Comments") %> by  <%# Eval("Username")%> on <%# Eval("CommDate", "{0:d}")%> at <%# Eval("CommmTime", "{0:T}")%> <br />
                          
                     </ItemTemplate>
                                               
                </asp:Repeater>
               
                <asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:fishconn %>" ProviderName="<%$ ConnectionStrings:fishconn.ProviderName %>" SelectCommand="SELECT [Username], [Comments], [CommDate], [CommmTime] FROM [tblPhotoComments] WHERE ([PhotoID] = ?) ORDER BY [CommDate], [CommmTime]">
                    <SelectParameters>
                        <asp:QueryStringParameter Name="PhotoID" QueryStringField="PhotoID" Type="Int32" />
                    </SelectParameters>

                </asp:SqlDataSource></td>
                    <td><asp:Repeater ID="Repeater4" runat="server" DataSourceID="SqlDataSource2">
                    <ItemTemplate>
                      <%# Eval("Username") %> <br />
                        </ItemTemplate>

                </asp:Repeater>
                         
                <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:fishconn %>" ProviderName="<%$ ConnectionStrings:fishconn.ProviderName %>" SelectCommand="SELECT [Username] FROM [tblPhotoLike] WHERE ([PhotoID] = ?) ORDER BY [PhotoLikeID] DESC">
               <SelectParameters>
                   <asp:QueryStringParameter Name="PhotoID" QueryStringField="PhotoID" Type="Int32" />
               </SelectParameters>
           </asp:SqlDataSource>

                    </td>
                    <td> <asp:Repeater ID="Repeater3" runat="server" DataSourceID ="SqlDataSource4">
                         <ItemTemplate>
                   
                           [<%# Eval("TagDescription") %>]
                  
               </ItemTemplate>

                         </asp:Repeater>

                        <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:fishconn %>" ProviderName="<%$ ConnectionStrings:fishconn.ProviderName %>" SelectCommand="SELECT tblTags.TagDescription FROM (tblPhotoTag INNER JOIN tblTags ON tblPhotoTag.TagID = tblTags.TagID) WHERE (tblPhotoTag.PhotoID = ?)">
               <SelectParameters>
                   <asp:QueryStringParameter Name="?" QueryStringField="PhotoID" />
               </SelectParameters>
           </asp:SqlDataSource>
                    </td>
                </tr>
            </table>
            </td>
        </tr>
          
        <tr>
            <td class="auto-style1">
                <asp:CheckBox ID="chkProfilePict" runat="server" /></td>
            <td class="auto-style2">Make Profile Picture</td>
            
        </tr>
        <tr>
            <td class="auto-style1">
                Date Uploaded</td>
            <td class="auto-style2">
                <asp:Label ID="lbldateup" runat="server" Text='<%# Eval("Dateupload", "{0:d}")%>'></asp:Label>
            </td>
            
        </tr>
        <tr>
            <td class="auto-style1">
                Time Uploaded</td>
            <td class="auto-style2">
               <asp:Label ID="lbltimeup" runat="server" Text='<%# Eval("TimeUpload", "{0:T}")%>'></asp:Label>
            </td>
            
        </tr>
        <tr>
            <td class="auto-style1">Caption:</td>
            <td class="auto-style2">
                <asp:TextBox ID="txtCaption" runat="server" Text='<%# Bind("Caption")%>' Height="89px" TextMode="MultiLine" Width="238px"></asp:TextBox></td>
            
        </tr>
        <tr>
            <td class="auto-style1">Latitude</td>
            <td class="auto-style2">
                <asp:TextBox ID="TxtLat" runat="server" Text='<%# Eval("LatLoc", "{0:0.########}")%>' CausesValidation="True"></asp:TextBox>
                 <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="TxtLat" ValidationExpression="^[-+]?\d*\.?\d*$" ErrorMessage="Enter a valid number" ForeColor="Red"></asp:RegularExpressionValidator>
                 <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TxtLat" ErrorMessage="Latitude is required" ForeColor="Red"></asp:RequiredFieldValidator>
                  <asp:RangeValidator ID="RangeValidator2" runat="server" ErrorMessage="RangeValidator" ControlToValidate="TxtLat" ForeColor="Red" MaximumValue="180" MinimumValue="-180" type="Double" >-180 To 180</asp:RangeValidator>
             </td>
    
        </tr>
           <tr>
            <td class="auto-style1">Longitude</td>
            <td class="auto-style2"><asp:TextBox ID="TxtLong" runat="server" Text='<%# Eval("LongLoc", "{0:0.########}")%>' CausesValidation="True"></asp:TextBox>
                  <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TxtLong" ValidationExpression="^[-+]?\d*\.?\d*$" ErrorMessage="Enter a valid Number" ForeColor="Red"></asp:RegularExpressionValidator> 
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TxtLong" ErrorMessage="Longitudeis Required" ForeColor="Red"></asp:RequiredFieldValidator>
                  <asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="RangeValidator" ControlToValidate="TxtLong" ForeColor="Red" MaximumValue="180" MinimumValue="-180" type="Double">-180 To 180</asp:RangeValidator>
                 </td>
               
        </tr>
        
           
   
  </table>
     <asp:HiddenField ID="hiddenphotoid" runat="server" Value='<%# Bind("PhotoID")%>' />
             <asp:HiddenField ID="Hiddensmallurl" runat="server" Value='<%# Bind("SmallUrl")%>' />
             <asp:HiddenField ID="HiddenUrl" runat="server" Value='<%# Bind("Url")%>' />
 </ItemTemplate>

        <LayoutTemplate>
            <div id="itemPlaceholderContainer" runat="server" style="">
                <span runat="server" id="itemPlaceholder" />
            </div>
            <div style="">
            </div>
        </LayoutTemplate>
        <SelectedItemTemplate>
            <span style="">Url:
            <asp:Label ID="UrlLabel" runat="server" Text='<%# Eval("Url") %>' />
            <br />
            Dateupload:
            <asp:Label ID="DateuploadLabel" runat="server" Text='<%# Eval("Dateupload") %>' />
            <br />
            TimeUpload:
            <asp:Label ID="TimeUploadLabel" runat="server" Text='<%# Eval("TimeUpload") %>' />
            <br />
            Caption:
            <asp:Label ID="CaptionLabel" runat="server" Text='<%# Eval("Caption") %>' />
            <br />
            LatLoc:
            <asp:Label ID="LatLocLabel" runat="server" Text='<%# Eval("LatLoc") %>' />
            <br />
            LongLoc:
            <asp:Label ID="LongLocLabel" runat="server" Text='<%# Eval("LongLoc") %>' />
            <br />
            PhotoID:
            <asp:Label ID="PhotoIDLabel" runat="server" Text='<%# Eval("PhotoID") %>' />
            <br />
<br /></span>
        </SelectedItemTemplate>
    </asp:ListView>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:fishconn %>" ProviderName="<%$ ConnectionStrings:fishconn.ProviderName %>" SelectCommand="SELECT [Url], [SmallUrl], [Dateupload], [TimeUpload], [Caption], [LatLoc], [LongLoc], [PhotoID] FROM [tblPhoto] WHERE (([PhotoID] = ?) AND ([UserName] = ?) AND ([Actv] = 'A'))">
        <SelectParameters>
            <asp:QueryStringParameter Name="PhotoID" QueryStringField="PhotoID" Type="Int32" />
            <asp:ControlParameter ControlID="hiddenUserName" Name="UserName" PropertyName="Value" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
   <asp:Label ID="lblDeleteMsg" runat="server" Text="" ForeColor="Red"></asp:Label>
    
    <table> <tr>
            <td class="auto-style6">
                <asp:Button ID="btnDelete" runat="server" Text="Delete" CausesValidation="False" />&nbsp;<ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" ConfirmText="Are you sure you want to delete? This action cannot be undone." TargetControlID="btnDelete"></ajaxToolkit:ConfirmButtonExtender> </td>
            <td class="auto-style4">
                <asp:Button ID="btnUpdate" runat="server" Text="Update" />
                <ajaxToolkit:ConfirmButtonExtender ID="btnUpdate_RoundedCornersExtender" runat="server" Enabled="True" TargetControlID="btnUpdate" ConfirmText="Are you sure you want to Update? This action cannot be undone.">
                </ajaxToolkit:ConfirmButtonExtender>
                &nbsp;&nbsp;&nbsp;
                </td>
            
            <td class="auto-style4">
                <input id="Button1" type="button" value="View on Google Map" onclick ="showmap()" />  </td>
            
        </tr></table>
    
    <asp:HiddenField ID="HiddenField1" runat="server" Value="0" />
    
         <asp:HiddenField ID="hiddenUserName" runat="server" Value="0" />
    
        
        <div class="PopupHeader" id="PopupHeader" style ="text-align : center">Map of Fishing Area where Picture was taken.</div>
                <div id="map_canvas" class="PopupBody" style="width: 800px; height: 600px" >
                    </div>
                <div class="Controls" >
                    
                    &nbsp;</div>
        
            
        
    

   
    
</asp:Content>
